package com.example.service.impl;

import com.example.mapper.DeptLogMapper;
import com.example.pojo.DeptLog;
import com.example.service.DeptLogService;
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DeptLogServiceImpl implements DeptLogService {

    @Autowired
    private DeptLogMapper deptLogMapper;

    @Transactional(propagation = Propagation.REQUIRES_NEW)//(propagation = Propagation.REQUIRES_NEW)
    //Propagation.REQUIRED: 默认值,有事务就加入,没有事务就开启新事务
    //Propagation.REQUIRES_NEW: 需要新事务,无论有没有事务,都开启新事务
    //Propagation.SUPPORTS: 有事务就加入,没有事务就在无事务的环境中运行
    //Propagation.NOT_SUPPORTED: 有事务就挂起(在无事务的环境中运行,
    // 如果抛出异常会导致其他事务回滚，而本身并不受影响),没有事务就开启新事务
    //Propagation.MANDATORY: 有事务就加入,没有事务就抛异常
    //Propagation.NEVER: 有事务就抛异常,没有事务就开启新事务
    //Propagation.NESTED: 有事务就嵌套,没有事务就开启新事务
    @Override
    public void insert(DeptLog deptLog) {
        deptLogMapper.insert(deptLog);
    }
}
